<template>
	<view class="jiankangsc">
		<headertop title="健康商城" str1="oridei" :back1="back1"></headertop>
		<image :src="_static('/images/Group 11695@2x.png')" class="jiankangscback" mode="widthFix">
		</image>
		<view class="" :style="{'margin-top':statusBarHeight+'px','width':'100%','height':barHeight+'px'}">
		</view>
		<view class="bottomcontent">
			<view class="center">
				<view class="headerline">
					<view class="lefttitle">
						<image :src="_static('/images/Group 11682@2x.png')" class="leftimg" mode="">
						</image>
						<span>全部设备</span>
					</view>
					<view class="myshebeitext" @click="goshebei">
						<span style="margin-right:8rpx ;">我的设备</span>
						<image :src="_static('/images/arrowright1.png')" mode=""></image>
					</view>
				</view>
				<view class="contents">
					<view class="itemb" v-for="item in list" :key="item.id" @click="gopage(item)">
						<image :src="item['image']" class="itembimg" mode=""></image>
						<view class="texts">
							<view class="t1">
								{{item['title']}}
							</view>
							<view class="t2">
								{{item['subtitle']}}
							</view>
							<view class="t3">
								￥{{item['price'][0]}}/天
							</view>
							<view class="btnlj" @click="gopage(item,'立即租用')">
								立即租用
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="" style="height: 200rpx;">

		</view>
		<Tabbar page="/pages/shoppingmal/index"></Tabbar>
	</view>
</template>

<script setup>
	import Tabbar from '@/components/tabbar.vue'
	import headertop from '@/components/header.vue'
	import {
		_static
	} from '@/ulm/utils/url.js'
	import ulm, {
		$api
	} from '@/ulm';
	import {
		ref,
		reactive,
		onMounted
	} from 'vue'
	import {
		onPageScroll,
		onLoad,
		onShow,
		onReachBottom
	} from "@dcloudio/uni-app";

	const statusBarHeight = ref('')
	const texts = ref('')
	const barHeight = ref('')
	const back1 = ref('')
	const total = ref(0)
	const list = ref([])
	const query = reactive({
		page: 1,
		list_rows: 10
	})
	const active = ref(2)
	onLoad(() => {
		init()
	})
	onReachBottom(() => {
		if (total.value > list.value) {
			query.page++
			init()
		}
	})
	onMounted(() => {
		statusBarHeight.value = uni.getSystemInfoSync().statusBarHeight
		const {
			top,
			height
		} = wx.getMenuButtonBoundingClientRect();
		barHeight.value = height ? height + (top - statusBarHeight.value) * 2 : 38;
	})
	onPageScroll((e) => {
		if (e.scrollTop > 100) {
			back1.value = '#81D6FF'
		} else {
			back1.value = ''
		}
	})

	function gopage(item, str) {
		if (str == '立即租用') {
			uni.navigateTo({
				url: '/sub_shoppingmal/index/zuliinfo?id=' + item.id
			})
		} else {
			uni.navigateTo({
				url: '/sub_shoppingmal/index/zulidetail?id=' + item.id
			})
		}
	}
	async function init() {
		const res = await $api.rentgoods(query)
		if (res.code == 1) {
			list.value.push(...res.data.data)
			total.value = res.data.total
		}
	}

	function goshebei() {
		uni.navigateTo({
			url: '/sub_shoppingmal/index/myshebei'
		})
	}
</script>
<style lang="scss">
	.jiankangsc {
		width: 100%;
		overflow: hidden;
		position: relative;

		.jiankangscback {
			width: 100%;
			position: absolute;
			z-index: -1;
		}

		.bottomcontent {
			width: 100%;
			min-height: 1134rpx;
			background: #FFFFFF;
			box-shadow: 0rpx -4rpx 8rpx 0rpx rgba(180, 180, 180, 0.31);
			border-radius: 48rpx 48rpx 0rpx 0rpx;
			margin-top: 328rpx;
			overflow: hidden;

			.center {
				width: 686rpx;
				margin: auto;
				margin-top: 32rpx;
				overflow: hidden;

				.contents {
					width: 100%;
					overflow: hidden;
					margin-top: 28rpx;

					.itemb {
						width: 686rpx;
						height: 184rpx;
						background: #F7F8FA;
						border-radius: 16rpx 16rpx 16rpx 16rpx;
						display: flex;
						align-items: center;
						margin-bottom: 28rpx;

						.itembimg {
							width: 144rpx;
							height: 144rpx;
							border-radius: 12rpx 12rpx 12rpx 12rpx;
							margin-left: 20rpx;
						}

						.texts {
							width: 486rpx;
							overflow: hidden;
							margin-left: 16rpx;
							position: relative;

							.t1 {
								font-family: PingFang SC, PingFang SC;
								font-weight: 500;
								font-size: 28rpx;
								color: #1D2129;
								white-space: nowrap; // 防止文本换行
								overflow: hidden; // 隐藏溢出的文本
								text-overflow: ellipsis; // 显示省略号
							}

							.t2 {
								font-family: PingFang SC, PingFang SC;
								font-weight: 400;
								font-size: 24rpx;
								color: #4E5969;
								white-space: nowrap; // 防止文本换行
								overflow: hidden; // 隐藏溢出的文本
								text-overflow: ellipsis; // 显示省略号
								margin-top: 16rpx;
							}

							.t3 {
								font-family: PingFang SC, PingFang SC;
								font-weight: bold;
								font-size: 28rpx;
								color: #F53F3F;
								margin-top: 38rpx;
							}

							.btnlj {
								text-align: center;
								line-height: 48rpx;
								width: 142rpx;
								height: 48rpx;
								background: #2AB4F5;
								border-radius: 4rpx 4rpx 4rpx 4rpx;
								font-family: PingFang SC, PingFang SC;
								font-weight: 400;
								font-size: 24rpx;
								color: #FFFFFF;
								position: absolute;
								right: 0%;
								bottom: 0%;
							}
						}
					}
				}

				.headerline {
					width: 100%;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.lefttitle {
						display: flex;
						align-items: center;
						font-family: PingFang SC, PingFang SC;
						font-weight: bold;
						font-size: 32rpx;
						color: #1D2129;

						.leftimg {
							width: 34rpx;
							height: 20rpx;
							margin-right: 14rpx;
						}
					}

					.myshebeitext {
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #2AB4F5;
						display: flex;
						align-items: center;

						image {
							width: 20rpx;
							height: 20rpx;
						}
					}
				}
			}
		}
	}
</style>